
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.util.Arrays" %>
<%@include file="/public.jsp"%>
<%--
  Created by IntelliJ IDEA.
  User: Yzk20
  Date: 2025/6/24
  Time: 8:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="css/styless.css">
</head>
<body>
<form>
<%
    String bookName=request.getParameter("bookName");
    Statement stmt=conn.createStatement();
    String sql="SELECT * FROM books t WHERE " +" 1=1 ";
    if(null!=bookName){
        sql=sql+" AND  t.bookName LIKE '%"+bookName+"%' ";
    }

    ResultSet rs=stmt.executeQuery(sql);
%>
<table align="center" >
    <h1 align="center">欢迎进入图书信息</h1>
    <tr>
        <td>图书名称：<input type="text" name="bookName" id="bookName"></td>
    </tr>
    <tr>
        <td align="center" >
            <input type="hidden" name="actionType" value="book">
            <input type="submit" value="查询" >
           <input type="button" value="添加" onclick="book_add()">
        </td>
    </tr>
</table>
<hr>
<table align="center" width="80%" berder="1" >
    <tr>
        <td>图书ID</td>
        <td>图书名称</td>
        <td>图书类型</td>
        <td>作者</td>
        <td>出版日期</td>
        <td>图书是否被借阅</td>
        <td>操作</td>

    </tr>
    <tbody id="devList">
    <tr>
<%
    while(rs.next()) {
%>
    <tr>
        <td><%=rs.getString("bookid")%></td>
        <td><%=rs.getString("bookName")%></td>
        <td><%=rs.getString("bookType")%></td>
        <td><%=rs.getString("author")%></td>
        <td><%=rs.getString("date")%></td>
        <td><%=rs.getString("status")%></td>
        <td>
            <input type="button" value="修改" onclick="book_update(<%=rs.getString("bookid")%>)">
            <input type="button" value="删除" onclick="book_delete(<%=rs.getString("bookid")%>)">
        </td>
<%}%>

    </tr>
    </tbody>
</table>
</form>
<script>
    function book_add(){

        window.location.href = "book/book_add.jsp"
    }
    function book_update(bookid){
        window.location.href = "book/book_update.jsp?bookid="+ bookid;
    }
    function book_delete(bookid){
        window.location.href = "book/book_delete.jsp?bookid="+ bookid;
    }
</script>
</from>
</body>
</html>
